<<<<<<< HEAD
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DiskFactory : MonoBehaviour
{
    public GameObject diskPrefab = null;
    private List<DiskData> used = new List<DiskData>();
    private List<DiskData> free = new List<DiskData>();

    public GameObject GetDisk(int round)
    {
        int choice = 0;
        int scope1 = 3, scope2 = 6, scope3 = 9;
        float startY = -10f;
        diskPrefab = null;

        for (int i = 0; i < free.Count; i++)
        {
            if (free[i].tag == tag)
            {
                diskPrefab = free[i].gameObject;
                free.Remove(free[i]);
                break;
            }
        }
        if (diskPrefab == null)
        {
            if (round == 1)
                choice = Random.Range(0, scope1);
            else if (round == 2)
                choice = Random.Range(0, scope2);
            else if (round == 3)
                choice = Random.Range(0, scope3);
            if (choice <= scope1)
                diskPrefab = Instantiate(Resources.Load<GameObject>("Prefabs/disk1"), new Vector3(0, startY, 0), Quaternion.identity);
            else if (choice <= scope2)
                diskPrefab = Instantiate(Resources.Load<GameObject>("Prefabs/disk2"), new Vector3(0, startY, 0), Quaternion.identity);
            else
                diskPrefab = Instantiate(Resources.Load<GameObject>("Prefabs/disk3"), new Vector3(0, startY, 0), Quaternion.identity);

            float ranX = Random.Range(-1f, -1f) < 0 ? -1 : 1;
            diskPrefab.GetComponent<DiskData>().direction = new Vector3(ranX, startY, 0);
            diskPrefab.transform.localScale = diskPrefab.GetComponent<DiskData>().scale;
        }
        used.Add(diskPrefab.GetComponent<DiskData>());
        return diskPrefab;
    }

    public void FreeDisk(GameObject disk)
    {
        for (int i = 0; i < used.Count; i++)
        {
            if (disk.GetInstanceID() == used[i].gameObject.GetInstanceID())
            {
                used[i].gameObject.SetActive(false);
                free.Add(used[i]);
                used.Remove(used[i]);
                break;
            }
        }
    }

=======
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DiskFactory : MonoBehaviour
{
    public GameObject diskPrefab = null;
    private List<DiskData> used = new List<DiskData>();
    private List<DiskData> free = new List<DiskData>();

    public GameObject GetDisk(int round)
    {
        int choice = 0;
        int scope1 = 3, scope2 = 6, scope3 = 9;
        float startY = -10f;
        diskPrefab = null;

        for (int i = 0; i < free.Count; i++)
        {
            if (free[i].tag == tag)
            {
                diskPrefab = free[i].gameObject;
                free.Remove(free[i]);
                break;
            }
        }
        if (diskPrefab == null)
        {
            if (round == 1)
                choice = Random.Range(0, scope1);
            else if (round == 2)
                choice = Random.Range(0, scope2);
            else if (round == 3)
                choice = Random.Range(0, scope3);
            if (choice <= scope1)
                diskPrefab = Instantiate(Resources.Load<GameObject>("Prefabs/disk1"), new Vector3(0, startY, 0), Quaternion.identity);
            else if (choice <= scope2)
                diskPrefab = Instantiate(Resources.Load<GameObject>("Prefabs/disk2"), new Vector3(0, startY, 0), Quaternion.identity);
            else
                diskPrefab = Instantiate(Resources.Load<GameObject>("Prefabs/disk3"), new Vector3(0, startY, 0), Quaternion.identity);

            float ranX = Random.Range(-1f, -1f) < 0 ? -1 : 1;
            diskPrefab.GetComponent<DiskData>().direction = new Vector3(ranX, startY, 0);
            diskPrefab.transform.localScale = diskPrefab.GetComponent<DiskData>().scale;
        }
        used.Add(diskPrefab.GetComponent<DiskData>());
        return diskPrefab;
    }

    public void FreeDisk(GameObject disk)
    {
        for (int i = 0; i < used.Count; i++)
        {
            if (disk.GetInstanceID() == used[i].gameObject.GetInstanceID())
            {
                used[i].gameObject.SetActive(false);
                free.Add(used[i]);
                used.Remove(used[i]);
                break;
            }
        }
    }

>>>>>>> af278523501920b14a6298f03aa4bd9ad9d33c2d
}